import time

import numpy as np
import pandas as pd
from pyecharts.charts import Line
import pyecharts.options as opts
from pyecharts.globals import ThemeType


chart = Line(
    # 设置主题、画布宽度、高度等信息
    init_opts=opts.InitOpts(theme=ThemeType.DARK, width="1200px", height="600px"),
    # 是否内嵌js 默认false
    # render_opts=opts.RenderOpts(is_embed_js=True)
)
# 全局设置
chart.set_global_opts(
    title_opts=opts.TitleOpts(title="Line-基本示例", ),
    # 工具箱配置
    toolbox_opts=opts.ToolboxOpts(is_show=True),
    # 区域缩放配置
    datazoom_opts=[opts.DataZoomOpts(is_show=True)],
)

# 添加数据
datacnt = 20
x_data = pd.date_range(start="2020-01-01", periods=datacnt).to_list()
y_data = np.random.randint(low=0, high=1000, size=datacnt).tolist()
y2_data = np.random.randint(low=0, high=1000, size=datacnt).tolist()

chart.add_xaxis(x_data)
chart.add_yaxis("商家A", y_data, is_smooth=True)
chart.add_yaxis("商家B", y2_data)

chart.render("line.html")

